##################################################################################################################################
#
# Copyright (C) 2008-2012 Mind System Connection. Lda. Part of Daidze Software, created by Siqsuruq. All other rights reserved.
#
# Mind System Connection Webpage: www.msysc.org
# Daidze Software Page: www.daidze.com www.daidze.org
# E-mail: admin@msysc.org, siqsuruq@gmail.com
#
# Thanks to: Glenn Jackman
##################################################################################################################################

proc remove_empty_from_list {my_list} {
	set non_empty [struct::list filter [struct::list flatten $my_list] {apply {{x} {expr {[string length $x] > 0}}}}]
	return $non_empty
}

proc shuffle_list { list } {
      set newlist [list]
      foreach element $list {
          lappend newlist [list [expr { rand() }] $element]
      }
      set retval [list]
      foreach pair [lsort -real -index 0 $newlist] {
          foreach { random item } $pair {
          lappend retval $item
          }
      }
      return $retval
  }